<template>
  <view class="tabbarBox">
    <view v-for="(item, index) in tabbarList" :key="index" :class="['tabbarItem', getTab(item.tabbarIndex) ? 'active' : '']" @click="changeTab(item.tabbarIndex)">
      <fui-icon :color="getTab(item.tabbarIndex) ? '#000000' : '#000000'" :name="getTab(item.tabbarIndex) ? item.iconSelect : item.icon"></fui-icon>
      <view class="textStyle" v-if="getTab(item.tabbarIndex)">{{ item.text }}</view>
    </view>
  </view>
</template>

<script setup lang="ts">
import fuiIcon from "@/components/firstui/fui-icon/fui-icon.vue";
import Nav from "@/router";
import Store from "@/store";
const tabbarList = [
  {
    text: "首页",
    icon: "home",
    iconSelect: "home-fill",
    tabbarIndex: 1,
  },
  {
    text: "首页",
    icon: "classify",
    iconSelect: "classify-fill",
    tabbarIndex: 2,
  },
  {
    text: "首页",
    icon: "find",
    iconSelect: "find-fill",
    tabbarIndex: 3,
  },
  {
    text: "首页",
    icon: "my",
    iconSelect: "my-fill",
    tabbarIndex: 4,
  },
];
const changeTab = (index: number) => {
  Nav.NavSwitchTab(index);
};
const getTab = (index: number) => Store.Common.tabbarIndex === index;
</script>
<style scoped>
.tabbarBox {
  width: 750rpx;
  height: 120rpx;
  background-color: #fbfcfd;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top-left-radius: 40rpx;
  border-top-right-radius: 40rpx;
}
.tabbarItem {
  width: 120rpx;
  height: 120rpx;
  background-color: transparent;
  border-radius: 120rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.5s;
  transform: translateY(10%);
  position: relative;
}
.textStyle {
  position: absolute;
  bottom: -40rpx;
  left: 0;
  display: block;
  width: 120rpx;
  height: 40rpx;
  line-height: 40rpx;
  font-size: 25rpx;
  text-align: center;
  animation: textAct 1s;
  color: black;
}
.active {
  background-color: white;
  color: white;
  font-weight: bold;
  transform: scale(1.2);
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  transform: translateY(-60rpx);
  position: relative;
  /* border-top: 10rpx solid white;
  border-left: 30rpx solid white;
  border-right: 30rpx solid white; */
}
@keyframes textAct {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
</style>
